/**
 *
 *
 * @param {原始日期的字符串} originDate
 * @param {选择格式化的类型,1为日期加时分秒,2为只要日期,默认为1} type
 * @return {格式化后的日期}
 */
export default function formatDate(originDate, type = 1) {
  const dt = new Date(originDate);

  const y = dt.getFullYear();
  const m = dt.getMonth() + 1 + '';
  const d = dt.getDate() + '';
  const hh = dt.getHours() + '';
  const mm = dt.getMinutes() + '';
  const ss = dt.getSeconds() + '';

  if (type === 2) {
    return `${y}-${m}-${d}`;
  }
  return `${y}-${m}-${d}- ${hh}:${mm}:${ss}`;
}
